package com.gexiaobao.pigeon.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.LinearLayoutManager
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.ext.init
import com.gexiaobao.pigeon.app.model.bean.AssignInfo
import com.gexiaobao.pigeon.ui.adapter.AdapterBonusDetail
import com.yanzhenjie.recyclerview.SwipeRecyclerView

/**
 * @Author      : hxw
 * @Date        : 2024/7/23 10:00
 * @Describe    :
 */
class RxDialogBonusDetail(context: Context?, data: ArrayList<AssignInfo>) : RxDialog(context!!) {

    private lateinit var tvDialogBonusDetailClose: AppCompatButton
    private lateinit var swipeRecyclerView: SwipeRecyclerView
    private lateinit var mAdapter: AdapterBonusDetail
    private var mData: ArrayList<AssignInfo>? = null

    init {
        this.mData = data
        initView()
    }

    @SuppressLint("MissingInflatedId", "NotifyDataSetChanged")
    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_bonus_detail, null)
        tvDialogBonusDetailClose = dialogView.findViewById(R.id.tvDialogBonusDetailClose)
        swipeRecyclerView = dialogView.findViewById(R.id.swipeRecyclerViewBonus)

        mAdapter = AdapterBonusDetail()
        swipeRecyclerView.layoutManager = LinearLayoutManager(context)
        swipeRecyclerView.adapter = mAdapter
        if (mData != null) {
            mAdapter.setList(mData)
            mAdapter.notifyDataSetChanged()
        }

        setContentView(dialogView)
    }

    fun setSureListener(listener: View.OnClickListener?) {
        tvDialogBonusDetailClose.setOnClickListener(listener)
    }
}